<?php

namespace app\api\controller;

use app\common\controller\Api;
use app\common\model\Article as ArticleModel;

class Article extends Api
{
    protected $noNeedLogin = ['*'];


    public function list()
    {
        $admin_id = $this->request->param('admin_id');
        $grouping_id = $this->request->param('grouping_id');

        $article = ArticleModel::where(['admin_id'=>$admin_id,'status' => 1])
            ->where('FIND_IN_SET(:grouping_id, grouping_id)', ['grouping_id' => $grouping_id])
            ->select();
//        if(!$article){
//            $this->success('文章不存在');
//        }else{
            $this->success('获取成功',$article);
//        }
    }

    public function info()
    {
        $admin_id = $this->request->param('admin_id');
        $article_id = $this->request->param('article_id');

        $article = ArticleModel::where(['admin_id'=>$admin_id,'id'=>$article_id,'status' => 1])->find();
        if(!$article){
            $this->error('文章不存在');
        }else{
            $this->success('获取成功',$article);
        }
    }
}